home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-valboo.adb < prev    next >
Text File  |  1996-01-30  |  3KB  |  57 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --                      S Y S T E M . V A L _ B O O L                       --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.7 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with System.Val_Util; use System.Val_Util;
  27.  
  28. package body System.Val_Bool is
  29.  
  30.    -------------------
  31.    -- Value_Boolean --
  32.    -------------------
  33.  
  34.    function Value_Boolean (Str : String) return Boolean is
  35.       F : Natural;
  36.       L : Natural;
  37.       S : String (Str'Range) := Str;
  38.  
  39.    begin
  40.       Normalize_String (S, F, L);
  41.  
  42.       if S (F .. L) = "TRUE" then
  43.          return True;
  44.       end if;
  45.  
  46.       if S (F .. L) = "FALSE" then
  47.          return False;
  48.       end if;
  49.  
  50.       raise Constraint_Error;
  51.  
  52.       --  Above should use elsif, but this doesn't work in GNAT version 1.81???
  53.  
  54.    end Value_Boolean;
  55.  
  56. end System.Val_Bool;
  57.